package pers.zh.parking.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import pers.zh.parking.dao.PkUserMapper;
import pers.zh.parking.po.PkUser;

@Service
public class UserService implements IUserService {

    @Autowired
    PkUserMapper userMapper;

    @Override
    public boolean exist(String account) {
        return userMapper.getUserByAccount(account) > 0;
    }

    @Override
    public PkUser validate(String account, String password) {
        return userMapper.validate(account, password);
    }

    @Override
    public boolean addUser(PkUser user) {
        user.setRole(1);
        return userMapper.insertSelective(user) > 0;
    }

    @Override
    public boolean update(PkUser user) {
        return userMapper.updateByPrimaryKeySelective(user) > 0;
    }

    @Override
    public PkUser getUser(Integer userId) {
        return userMapper.selectByPrimaryKey(userId);
    }

    @Override
    public boolean modifyPwd(PkUser user) {
        return userMapper.modifyPwd(user) > 0;
    }
}
